package org.opu.pc;

import java.util.List;

import javax.swing.UIManager;

import org.opu.pc.ui.client.MainView;
import org.opu.pc.ui.util.Logger;
import org.opu.pc.ui.util.NullableProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Yuriy Dunko
 */
public class App {

    @SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
        
    	try {
			UIManager.setLookAndFeel(
//                    "ch.randelshofer.quaqua.QuaquaLookAndFeel" // Mac look
//                    UIManager.getCrossPlatformLookAndFeelClassName()
                    UIManager.getSystemLookAndFeelClassName()
                    );
		} catch (Exception e) {
			Logger.getInstance().error(App.class, e);
		}
    	
		NullableProperties prop = NullableProperties.getInstance();
//        prop.setProperty("hibernate.dialect",
////        		"org.hibernate.dialect.PostgreSQLDialect"
//        		"org.hibernate.dialect.HSQLDialect"
//        		);
//        prop.setProperty("hibernate.show_sql", "true");
//        prop.setProperty("hibernate.hbm2ddl.auto",
////        		"validate"
//        		"create"
//        		);
//
//        prop.setProperty("jdbc.driverClassName",
////        		"org.postgresql.Driver"
//        		"org.hsqldb.jdbcDriver"
//        		);
//        prop.setProperty("jdbc.url",
////        		"jdbc:postgresql://localhost:5432/test"
//        		"jdbc:hsqldb:mem:test"
//        		);
////        prop.setProperty("jdbc.username", "yura");
////        prop.setProperty("jdbc.password", "123");
        prop.load();

        ApplicationContext context = new ClassPathXmlApplicationContext(
                "classpath:ui_applicationcontext.xml",
                "classpath:datasource_applicationcontext.xml",
                "classpath:dao_applicationcontext.xml",
                "classpath:sg_applicationcontext.xml",
                "classpath:publications_analysis_applicationcontext.xml",
                "classpath:services_applicationcontext.xml",
                "classpath:desktop_ui_applicationcontext.xml");

        List actions = (List) context.getBean("Actions");
        MainView view = (MainView) context.getBean("MainView");
        view.initActions(actions);
        view.fireState();
        view.asFrame().setVisible(true);
        view.asFrame().getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);
    }
}
